package com.egao.common.system.biz.impl;


import com.egao.common.core.damon.constant.Birthday;
import com.egao.common.core.damon.constant.UserConstant;
import com.egao.common.core.damon.results.BaseDao;
import com.egao.common.core.damon.utils.Utils;
import com.egao.common.system.biz.DictionaryDateBiz;
import com.egao.common.system.biz.UserBiz;
import com.egao.common.system.entity.DictionaryData;
import com.egao.common.system.entity.User;
import com.egao.common.system.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * 数据层实现类
 * @author : Doman
 * @date : 2020-05-27 15:04:13
 * @version ：1.0
 */
@Repository
public class DictionaryBizImpl extends BaseDao implements DictionaryDateBiz {

	@Autowired
	private EmailService emailService;

	@Override
	public List<DictionaryData> listAllByDictCode(DictionaryData dictionaryData) {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<DictionaryData> rm = new BeanPropertyRowMapper<DictionaryData>(DictionaryData.class);
		StringBuffer sql = new StringBuffer("select dd.dict_data_id");
		sql.append(",dd.dict_id,dd.dict_data_code,dd.dict_data_name,dd.sort_number");
		sql.append(",dd.comments");
		sql.append(" from sys_dictionary_data dd ");
		sql.append(" inner join sys_dictionary d on d.dict_id=dd.dict_id ");
		sql.append(" where d.deleted=0 and dd.deleted=0 ");
		if(Utils.isNotEmpty(dictionaryData)){
			if(Utils.isNotEmpty(dictionaryData.getDictCode())){
				sql.append(" and d.dict_code=:dict_code ");
				map.put("dict_code", dictionaryData.getDictCode());
			}
		}
		sql.append(" order by dd.sort_number asc");
		getMapParameter(sql, map);
		return jdbcTemplate.query(sql.toString(),map, rm);
	}



}
